﻿define(function (require) {
    require('models/group');
    var service = require('utility/service');
    window.GroupList = Backbone.Collection.extend({
        model: Group,
        comparator: function (e) {
        },
        initialize: function () {
            this.getAll();
        },
        getAll: function () {
            var _self = this;
            service.GetAllGroups_Cache(function (groups) {
                _self.add(groups);
                _self.trigger("getAll");
            });

        },
        getGroups: function(){
            return _.select(this.models, function (item) { return item.get("IsChoosed") });
        },
        resetModels: function(){
            _.each(this.models, function (model) { model.unChoose(); });
        }
    });
});